<%--
  Created by IntelliJ IDEA.
  User: cwx
  Date: 2018/3/22
  Time: 21:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Ajax</title>

    <script type="application/javascript" src="http://www.w3school.com.cn/jquery/jquery-1.11.1.min.js"></script>
    <script type="application/javascript">

        $(function () {
            $.ajax({
                url: "http://localhost:8080/testjson",
                type: "post",
                // dataType: "json",
                contentType:"application/json;charset=utf-8",
                data: '{ "descrption":"hello ajax","id":99}',
                success: function (data) {

                    alert("descrption= " + data.descrption);
                    alert("id = " + data.id);
                },
                error: function () {
                    alert("error");
                }
            });
        });
    </script>
</head>
<body>

</body>
</html>
